﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Data.Sql;

public partial class Manage_Send : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        //读取选中内容
        int k = GridView1.SelectedIndex;
        string Ono = GridView1.SelectedRow.Cells[1].Text;
        string Aaccount = GridView1.SelectedRow.Cells[2].Text;
        string connectionString = WebConfigurationManager.ConnectionStrings["ConnectionStrManager"].ConnectionString;
        using (SqlConnection conn = new SqlConnection(connectionString))
        {
            //再根据Dno，找到所有信息。
            try
            {
                string Ostate = "交易完成";
                //先通过Order找到所有state为已下订  的订单
                conn.Open();
                String sqlString = "update Manager_Order set Ostate = @Ostate, Ooktime = getdate()  where Ono = @Ono";
                SqlParameter[] parameters = { 
                                                new SqlParameter("@Ono", Ono) ,
                                                new SqlParameter("@Ostate", Ostate)
                                            };
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = sqlString;
                    cmd.Parameters.AddRange(parameters);
                    int rec = cmd.ExecuteNonQuery();
                }
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "exec vipLelProc @account";
                    SqlParameter[] parametersNew = { 
                                                    new SqlParameter("@account", Aaccount),
                                                };
                    cmd.Parameters.AddRange(parametersNew);
                    int rec = cmd.ExecuteNonQuery();
                }

            }
            catch (Exception ez)
            {
                Response.Write(@"<b>异常信息:</b>" + ez.Message);
            }
            finally
            {
                conn.Close();
            }
            Response.AddHeader("Refresh", "0");  //刷新当前页面
        }
    }
}